package views; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; public class Frame extends JFrame{ protected JPanel contentPanel; public Frame(String title){ FrameStack.getInstance().push(this); setTitle(title); setSize(500, 500); setLayout(new BorderLayout()); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); contentPanel = new JPanel(); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPanel.setBackground(Color.red); add(contentPanel, BorderLayout.CENTER); } public void setBackButtonActionListener(ActionListener a) { JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); JButton backButton = new JButton("Back"); buttonPanel.add(backButton); this.add(buttonPanel, BorderLayout.NORTH); backButton.addActionListener(a); } }